//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS FreeTier service.
///
/// You can use the Amazon Web Services Free Tier API to query programmatically your Free Tier usage data. Free Tier tracks your monthly usage data for all free tier offers that are associated with your Amazon Web Services account. You can use the Free Tier API to filter and show only the data that you want. Service endpoint The Free Tier API provides the following endpoint:  For more information, see Using the Amazon Web Services Free Tier in the Billing User Guide.
public struct FreeTier: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the FreeTier client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            amzTarget: "AWSFreeTierService",
            serviceName: "FreeTier",
            serviceIdentifier: "freetier",
            serviceProtocol: .json(version: "1.0"),
            apiVersion: "2023-09-07",
            endpoint: endpoint,
            errorType: FreeTierErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    ///  Returns a specific activity record that is available to the customer.
    @Sendable
    @inlinable
    public func getAccountActivity(_ input: GetAccountActivityRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetAccountActivityResponse {
        try await self.client.execute(
            operation: "GetAccountActivity", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    ///  Returns a specific activity record that is available to the customer.
    ///
    /// Parameters:
    ///   - activityId:  A unique identifier that identifies the activity.
    ///   - languageCode:  The language code used to return translated title and description fields.
    ///   - logger: Logger use during operation
    @inlinable
    public func getAccountActivity(
        activityId: String,
        languageCode: LanguageCode? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetAccountActivityResponse {
        let input = GetAccountActivityRequest(
            activityId: activityId, 
            languageCode: languageCode
        )
        return try await self.getAccountActivity(input, logger: logger)
    }

    ///  This returns all of the information related to the state of the account plan related to Free Tier.
    @Sendable
    @inlinable
    public func getAccountPlanState(_ input: GetAccountPlanStateRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetAccountPlanStateResponse {
        try await self.client.execute(
            operation: "GetAccountPlanState", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    ///  This returns all of the information related to the state of the account plan related to Free Tier.
    ///
    /// Parameters:
    ///   - logger: Logger use during operation
    @inlinable
    public func getAccountPlanState(
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetAccountPlanStateResponse {
        let input = GetAccountPlanStateRequest(
        )
        return try await self.getAccountPlanState(input, logger: logger)
    }

    /// Returns a list of all Free Tier usage objects that match your filters.
    @Sendable
    @inlinable
    public func getFreeTierUsage(_ input: GetFreeTierUsageRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetFreeTierUsageResponse {
        try await self.client.execute(
            operation: "GetFreeTierUsage", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns a list of all Free Tier usage objects that match your filters.
    ///
    /// Parameters:
    ///   - filter: An expression that specifies the conditions that you want each FreeTierUsage object to meet.
    ///   - maxResults: The maximum number of results to return in the response. MaxResults means that there can be up to the specified number of values, but there might be fewer results based on your filters.
    ///   - nextToken: The pagination token that indicates the next set of results to retrieve.
    ///   - logger: Logger use during operation
    @inlinable
    public func getFreeTierUsage(
        filter: Expression? = nil,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetFreeTierUsageResponse {
        let input = GetFreeTierUsageRequest(
            filter: filter, 
            maxResults: maxResults, 
            nextToken: nextToken
        )
        return try await self.getFreeTierUsage(input, logger: logger)
    }

    ///  Returns a list of activities that are available. This operation supports pagination and filtering by status.
    @Sendable
    @inlinable
    public func listAccountActivities(_ input: ListAccountActivitiesRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListAccountActivitiesResponse {
        try await self.client.execute(
            operation: "ListAccountActivities", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    ///  Returns a list of activities that are available. This operation supports pagination and filtering by status.
    ///
    /// Parameters:
    ///   - filterActivityStatuses:  The activity status filter. This field can be used to filter the response by activities status.
    ///   - languageCode:  The language code used to return translated titles.
    ///   - maxResults:  The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output.
    ///   - nextToken:  A token from a previous paginated response. If this is specified, the response includes records beginning from this token (inclusive), up to the number specified by maxResults.
    ///   - logger: Logger use during operation
    @inlinable
    public func listAccountActivities(
        filterActivityStatuses: [ActivityStatus]? = nil,
        languageCode: LanguageCode? = nil,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListAccountActivitiesResponse {
        let input = ListAccountActivitiesRequest(
            filterActivityStatuses: filterActivityStatuses, 
            languageCode: languageCode, 
            maxResults: maxResults, 
            nextToken: nextToken
        )
        return try await self.listAccountActivities(input, logger: logger)
    }

    ///  The account plan type for the Amazon Web Services account.
    @Sendable
    @inlinable
    public func upgradeAccountPlan(_ input: UpgradeAccountPlanRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UpgradeAccountPlanResponse {
        try await self.client.execute(
            operation: "UpgradeAccountPlan", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    ///  The account plan type for the Amazon Web Services account.
    ///
    /// Parameters:
    ///   - accountPlanType:  The target account plan type. This makes it explicit about the change and latest value of the accountPlanType.
    ///   - logger: Logger use during operation
    @inlinable
    public func upgradeAccountPlan(
        accountPlanType: AccountPlanType,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UpgradeAccountPlanResponse {
        let input = UpgradeAccountPlanRequest(
            accountPlanType: accountPlanType
        )
        return try await self.upgradeAccountPlan(input, logger: logger)
    }
}

extension FreeTier {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: FreeTier, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension FreeTier {
    /// Return PaginatorSequence for operation ``getFreeTierUsage(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func getFreeTierUsagePaginator(
        _ input: GetFreeTierUsageRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<GetFreeTierUsageRequest, GetFreeTierUsageResponse> {
        return .init(
            input: input,
            command: self.getFreeTierUsage,
            inputKey: \GetFreeTierUsageRequest.nextToken,
            outputKey: \GetFreeTierUsageResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``getFreeTierUsage(_:logger:)``.
    ///
    /// - Parameters:
    ///   - filter: An expression that specifies the conditions that you want each FreeTierUsage object to meet.
    ///   - maxResults: The maximum number of results to return in the response. MaxResults means that there can be up to the specified number of values, but there might be fewer results based on your filters.
    ///   - logger: Logger used for logging
    @inlinable
    public func getFreeTierUsagePaginator(
        filter: Expression? = nil,
        maxResults: Int? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<GetFreeTierUsageRequest, GetFreeTierUsageResponse> {
        let input = GetFreeTierUsageRequest(
            filter: filter, 
            maxResults: maxResults
        )
        return self.getFreeTierUsagePaginator(input, logger: logger)
    }

    /// Return PaginatorSequence for operation ``listAccountActivities(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listAccountActivitiesPaginator(
        _ input: ListAccountActivitiesRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListAccountActivitiesRequest, ListAccountActivitiesResponse> {
        return .init(
            input: input,
            command: self.listAccountActivities,
            inputKey: \ListAccountActivitiesRequest.nextToken,
            outputKey: \ListAccountActivitiesResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listAccountActivities(_:logger:)``.
    ///
    /// - Parameters:
    ///   - filterActivityStatuses:  The activity status filter. This field can be used to filter the response by activities status.
    ///   - languageCode:  The language code used to return translated titles.
    ///   - maxResults:  The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output.
    ///   - logger: Logger used for logging
    @inlinable
    public func listAccountActivitiesPaginator(
        filterActivityStatuses: [ActivityStatus]? = nil,
        languageCode: LanguageCode? = nil,
        maxResults: Int? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListAccountActivitiesRequest, ListAccountActivitiesResponse> {
        let input = ListAccountActivitiesRequest(
            filterActivityStatuses: filterActivityStatuses, 
            languageCode: languageCode, 
            maxResults: maxResults
        )
        return self.listAccountActivitiesPaginator(input, logger: logger)
    }
}

extension FreeTier.GetFreeTierUsageRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> FreeTier.GetFreeTierUsageRequest {
        return .init(
            filter: self.filter,
            maxResults: self.maxResults,
            nextToken: token
        )
    }
}

extension FreeTier.ListAccountActivitiesRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> FreeTier.ListAccountActivitiesRequest {
        return .init(
            filterActivityStatuses: self.filterActivityStatuses,
            languageCode: self.languageCode,
            maxResults: self.maxResults,
            nextToken: token
        )
    }
}
